import dict from './dict'
import formatter from './formatter'
import rules from './rules'
import hasPermission from './permission'
import minio from './minio'

import * as utils from './utils'
export default {
  install(app) {
    app.config.globalProperties.$dict = dict
    app.config.globalProperties.$rules = rules
    app.config.globalProperties.$utils = utils
    app.config.globalProperties.$formatter = formatter
    app.config.globalProperties.$hasPermission = hasPermission
    app.config.globalProperties.$minio = minio
  }
}


// 判断是否是移动端
export const isMobile = () => {
  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
    navigator.userAgent
  ) || window.innerWidth < 769
}

// 判断是否是CEF浏览器
export const isCEFBrowser = () => {
  // CEF浏览器通常会在用户代理字符串中包含Embedded字样
  // 也会包含Chrome但缺少其他常见的Chrome标识
  const ua = navigator.userAgent;
  const isCEF = ua.includes('Chrome') && 
               (ua.includes('Embedded') || 
                ua.includes('CEF') || 
                (ua.includes('Chrome') && !ua.includes('Safari')));
  
  return isCEF;
}

// 获取完整的图片URL
export const getFullImageUrl = (id) => {

  return new URL(`../assets/images/store/${id}.png`, import.meta.url).href
}
